import Vue from 'vue'
import UiConfirm from './UiConfirm'
export default function(message, title, option) {
  return new Promise((resolve, reject) => {
    const Instance = Vue.extend({
      components: { UiConfirm },
      render(h) {
        return h('UiConfirm', {
          props: {
            message: message,
            title: title,
            option: option
          },
          on: {
            close(action) {
              if (action === 'sure') {
                resolve(action)
              } else {
                reject(action)
              }
            }
          }
        })
      }
    })
    document.body.appendChild(new Instance().$mount().$el)
  })
}
